package cn.xfdzx.android.apps.shop.activity;

import android.app.Dialog;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.luck.picture.lib.tools.ToastUtils;

import butterknife.BindView;
import butterknife.OnClick;
import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.base.BaseMvpActivity;
import cn.xfdzx.android.apps.shop.util.ExampleUtil;
import cn.xfdzx.android.apps.shop.util.Utils;

/*
/* 关于页面
 */
public class AboutActivity extends BaseMvpActivity {
    @BindView(R.id.iv_back)
    ImageView ivBack;      //标题栏-左边按钮
    @BindView(R.id.tv_versionnum)
    TextView tv_versionnum;    //当前版本号
    @BindView(R.id.rl_checkversion)
    RelativeLayout rl_checkversion;  //检查版本
    @BindView(R.id.rl_share)
    RelativeLayout rl_share;   //分享好友
    @BindView(R.id.rl_useragreement)
    RelativeLayout rl_useragreement;   //用户协议
    @BindView(R.id.rl_privacy_agreement)
    RelativeLayout rl_privacy_agreement;   //隐私协议
    @BindView(R.id.rl_service_agreement)
    RelativeLayout rl_service_agreement;   //商家服务协议
    private Dialog dialog;//确认清除弹窗

    @Override
    public int getLayoutId() {
        return R.layout.activity_aboutour;
    }

    @Override
    public void initView() {

        tv_versionnum.setText("v"+ ExampleUtil.GetVersion(this));

            dialog = Utils.addDialog(this, R.layout.dialog, R.string.confirmclearcatch, R.string.confirm, new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                dialog.dismiss();
            }
        });
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void onError(Throwable throwable) {

    }

    @OnClick({R.id.iv_back, R.id.rl_checkversion, R.id.rl_useragreement, R.id.rl_privacy_agreement,R.id.rl_service_agreement})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:    //返回按钮点击
                finish();
                break;
            case R.id.rl_checkversion:   //检查版本点击

                ToastUtils.s(this,"当前已是最新版本");
                //TODO:接口待调试
                break;
            case R.id.rl_useragreement: //用户协议点击
                Intent intentuser = new Intent(this,UserAgreementActivity.class);
                intentuser.putExtra("type","0");
                startActivity(intentuser);
                break;
            case R.id.rl_privacy_agreement:   //隐私协议点击
                Intent intentprivacy = new Intent(this,UserAgreementActivity.class);
                intentprivacy.putExtra("type","1");
                startActivity(intentprivacy);
                break;
            case R.id.rl_service_agreement:   //商家服务协议点击
                Intent intentservice = new Intent(this,UserAgreementActivity.class);
                intentservice.putExtra("type","2");
                startActivity(intentservice);
                break;
        }
    }

    @Override
    protected void onDestroy() {
        if (dialog.isShowing()) {
            dialog.dismiss();

        }
        super.onDestroy();
    }

}
